package com.project.im.app.vo;

import com.project.im.common.enums.ResponseCode;
import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class ResponseVO<T> {
    private String code;
    private String msg;
    private T data;
    private String reqId;

    public static <T> ResponseVO<T> success(T data) {
        ResponseVO<T> responseVO = new ResponseVO<>();
        responseVO.setCode(ResponseCode.SUCCESS.getCode());
        responseVO.setMsg(ResponseCode.SUCCESS.getMsg());
        responseVO.setData(data);
        return responseVO;
    }

    public static <T> ResponseVO<T> success() {
        ResponseVO<T> responseVO = new ResponseVO<>();
        responseVO.setCode(ResponseCode.SUCCESS.getCode());
        responseVO.setMsg(ResponseCode.SUCCESS.getMsg());
        return responseVO;
    }

    public static <T> ResponseVO<T> fail(ResponseCode responseCode) {
        ResponseVO<T> responseVO = new ResponseVO<>();
        responseVO.setCode(responseCode.getCode());
        responseVO.setMsg(responseCode.getMsg());
        return responseVO;
    }

    public static <T> ResponseVO<T> fail(ResponseCode responseCode, T data) {
        ResponseVO<T> responseVO = new ResponseVO<>();
        responseVO.setCode(responseCode.getCode());
        responseVO.setMsg(responseCode.getMsg());
        responseVO.setData(data);
        return responseVO;
    }

    public static <T> ResponseVO<T> fail(ResponseCode responseCode, String msg) {
        ResponseVO<T> responseVO = new ResponseVO<>();
        responseVO.setCode(responseCode.getCode());
        responseVO.setMsg(msg);
        return responseVO;
    }

    public static <T> ResponseVO<T> fail(String code, String msg) {
        ResponseVO<T> responseVO = new ResponseVO<>();
        responseVO.setCode(code);
        responseVO.setMsg(msg);
        return responseVO;
    }
}
